﻿#include "DeviceRegisterCodec_Unregister.h"

#include "DataPackage_UdpCodec.h"
#include "RegisterCenter_Device.h"
#include "Device.h"

DeviceRegisterCodec_Unregister::DeviceRegisterCodec_Unregister()
{
  setObjectName(getClassNameFirstLow<DeviceRegisterCodec_Unregister>());
}

DeviceRegisterCodec_Unregister::~DeviceRegisterCodec_Unregister()
{

}

DataPackage_UdpCodec* DeviceRegisterCodec_Unregister::decode(DataPackage_UdpCodec* dataPackageInfo_Device)
{
  registerCenter_Device->deviceLogout(dataPackageInfo_Device->getDeviceId());
  return dataPackageInfo_Device->toAck(QByteArray().append(Unregister));//发送注销成功的反馈
}

RegisterCenter_Device* DeviceRegisterCodec_Unregister::getRegisterCenter_Device() const
{
  return registerCenter_Device;
}

DeviceRegisterCodec_Unregister* DeviceRegisterCodec_Unregister::setRegisterCenter_Device(RegisterCenter_Device* const registerCenter_Device)
{
  this->registerCenter_Device=registerCenter_Device;
  printInjection(this,registerCenter_Device);
  return this;
}

void DeviceRegisterCodec_Unregister::objectAutoInjection(QHash<QString,QObject*>* objMap)
{
  setRegisterCenter_Device(getObjFromMap<RegisterCenter_Device>(objMap));
}
